package com.lwj.widget.viewpagerindicator_demo.slice;

import com.lwj.widget.viewpagerindicator.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;

/**
 * MainAbilitySlice启动页
 *
 * @author name
 * @since 2021-03-20
 */
public class MainAbilitySlice extends AbilitySlice implements Component.ClickedListener {
    private Button bannerView;

    private Button carouseBut;

    private Button notCarouseBut;

    private Intent intent;

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);
        initView();
    }

    /**
     * 初始化参数
     */
    private void initView() {
        intent = new Intent();
        notCarouseBut = (Button) findComponentById(ResourceTable.Id_btn_not_carouse);
        carouseBut = (Button) findComponentById(ResourceTable.Id_btn_carouse);
        bannerView = (Button) findComponentById(ResourceTable.Id_btn_banner_view);
        notCarouseBut.setClickedListener(this);
        carouseBut.setClickedListener(this);
        bannerView.setClickedListener(this);
    }

    /**
     * 点击跳转页面
     *
     * @param component 上下文
     */
    @Override
    public void onClick(Component component) {
        switch (component.getId()) {
            case ResourceTable.Id_btn_banner_view:
                BannerViewAbilitySlice bannerViewAbilitySlice = new BannerViewAbilitySlice();
                present(bannerViewAbilitySlice, intent);
                break;
            case ResourceTable.Id_btn_carouse:
                CarouseAbilitySlice carouseAbilitySlice = new CarouseAbilitySlice();
                present(carouseAbilitySlice, intent);
                break;
            case ResourceTable.Id_btn_not_carouse:
                NotCarouselAbilitySlice notCarouselAbilitySlice = new NotCarouselAbilitySlice();
                present(notCarouselAbilitySlice, intent);
                break;
            default:
        }
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
